package com.cangxuan.app.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.cangxuan.app.R;
import com.google.android.material.tabs.TabLayout;

/**
 * 主页藏品盲盒
 * author:何程城
 */
public class HomeListBoxesFragment extends Fragment {
    TabLayout homeBoxesType;
    View parentView;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (parentView==null) {
            parentView = inflater.inflate(R.layout.fragment_home_list_boxes, container, false);
            homeBoxesType = parentView.findViewById(R.id.homeBoxesType);
            homeBoxesType.addTab(homeBoxesType.newTab().setText("S"));
            homeBoxesType.addTab(homeBoxesType.newTab().setText("SS"));
            homeBoxesType.addTab(homeBoxesType.newTab().setText("SSS"));
            homeBoxesType.addTab(homeBoxesType.newTab().setText("SSR"));
            /**
             * 点击标签项切换盲盒的等级
             */
            homeBoxesType.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                @Override
                public void onTabSelected(TabLayout.Tab tab) {
                    Toast toast = Toast.makeText(getContext(), "点击了"+tab.getText(), Toast.LENGTH_SHORT);
                    toast.show();
                }

                @Override
                public void onTabUnselected(TabLayout.Tab tab) {

                }

                @Override
                public void onTabReselected(TabLayout.Tab tab) {

                }
            });
        }

        return parentView;
    }

}
